﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PowerCreator.LMS.DL.Project.Entity;
using PowerCreator.LMS.Web.DL.Project;

public partial class Theme_Index_CourseDescription :PowerCreator.LMS.Web.Base.WebBasePage
{
    PowerCreator.LMS.Web.Course.Course opCourse = new PowerCreator.LMS.Web.Course.Course();
    protected PowerCreator.LMS.Web.Config.WebConfig config = new PowerCreator.LMS.Web.Config.WebConfig();
    PowerCreator.LMS.ViewQuery.ViewQuery vq = new PowerCreator.LMS.ViewQuery.ViewQuery();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string cid = Request.QueryString["CID"].ToString();
            //ViewState["CID"] = cid;
            DataBinderPageData(cid);
        }
    }
    protected override void InitPage()
    {
        base.InitPage();
    }

    private void DataBinderPageData(string cid)
    {
        PowerCreator.LMS.Course.Entity.VOTOCourse vo = new PowerCreator.LMS.Course.Entity.VOTOCourse();
        vo = opCourse.LoadVOTCourse(int.Parse(cid));
        if (vo.Course_Id>0)
        {
            this.Title = vo.CourseName+"简介";
            lbl_CourseName.Text = vo.CourseName;
            lbl_Createtime.Text = "发布时间：" + vo.CourseCreatetime + "&nbsp;&nbsp;点击量：";
            string sql = "select sum(ResourceClickNum) as sums from TResource where ResourceID in (select FKCoursersResourceID from TCourseResource where FKCourseresCourseID=" + vo.Course_Id.ToString() + ")";
            DataTable dt1 = new DataTable();
            dt1 = vq.Query(sql);
            if (dt1.Rows.Count > 0)
                lbl_Createtime.Text = lbl_Createtime.Text+dt1.Rows[0]["sums"].ToString();
            else
                lbl_Createtime.Text = lbl_Createtime.Text + "0";
            lbl_Pic.Text = "<img height=\"300\" width=\"280\" border=\"0\" src=\"" + vo.CourseImgUrl + "\" alt=\"课程图片\" />";
            lbl_author.Text = "主讲教师："+vo.CourseMostlyTeacherName;
            lbl_keshi.Text = "课程学时：" + vo.CoursePeriod.ToString();
            lbl_peixunleibie.Text = "培训类别：" + getTrainTypeName(vo.TrainType);
            lbl_peixunxingshi.Text = "培训形式：";
            if (vo.TrainFormat == 1)
                lbl_peixunxingshi.Text = lbl_peixunxingshi.Text + "网络";
            else if (vo.TrainFormat == 2)
                lbl_peixunxingshi.Text = lbl_peixunxingshi.Text + "面授";
            else 
                lbl_peixunxingshi.Text = lbl_peixunxingshi.Text + "面授加网络";
            lbl_xueduan.Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 学段：" + GetXueDuan(vo.Xueduan);
            lbl_xuenian.Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 学年：" + GetXueNian(vo.Xueduan);
            lbl_leixing.Text = "课程类型：";
            if (vo.CourseIsCompulsory == 1)
                lbl_leixing.Text = lbl_leixing.Text + "必修";
            else
                lbl_leixing.Text = lbl_leixing.Text + "选修";
            lit_jiaoshi.Text = GetTeacherMsg(vo.FKCourseMostlyTeacherID);
            lit_CourseContent.Text = vo.Description;
        }
    }
    private string getTrainTypeName(string TrainTypeIDs)
    {
        string rt = "";
        string sql = "select TrainTypeName from TO_TrainType where ID in ("+TrainTypeIDs+")";
        DataTable dt = new DataTable();
        dt = vq.Query(sql);
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (rt.Length>0)
                rt=rt+"、";
            rt = rt + dt.Rows[i]["TrainTypeName"].ToString();
        }
        return rt;

    }
    private string GetXueDuan(int id)
    {
        VOTOSchoolStage vo = new VOTOSchoolStage();
        TOSchoolStage obj=new TOSchoolStage();
        vo=obj.Load(id);
        return vo.SchoolStage;
    }
    private string GetXueNian(int id)
    {
        VOTOXueNian vo = new VOTOXueNian();
        TOXuenian obj = new TOXuenian();
        vo=obj.Load(id);
        return vo.XueNian;
    }
    private string GetXueKe(int id)
    {
        PowerCreator.LMS.Course.Entity.VOTCatalog vo=new PowerCreator.LMS.Course.Entity.VOTCatalog();
        PowerCreator.LMS.Web.Catalog.Catalog obj = new PowerCreator.LMS.Web.Catalog.Catalog();
        vo=obj.Load(id);
        return vo.CatalogName;
    }
    private string GetTeacherMsg(int id)
    {
        VOTOAdvancedUser vo = new VOTOAdvancedUser();
        TOAdvancedUser obj = new TOAdvancedUser();
        vo = obj.Load(id);
        return vo.Memo;
    }
}
